Introduction

This I had create a comunication between 2 or more boards, using I2C, ISP, or ESP. I decided to use I2C to link my light sensor board and the LCD screen board.

Documentation

Since I didn't know neither what I2C was, I read the 17th chapter of Make: AVR programming.

It explained in avery clear way the theory, how it worked and what I had to do.
In order to do it, I checked the Arduino's Wire library.
I tried to program it in avr c during the past weeks, but it was too hard for me since I had no background in programming.

In this page everything is explained pretty well. The connection I was looking for was a master-slave one, where the light sensor board is the master/reader, and the LCD screen is the slave/sender.

I2C

Since this assignment was way more hard then I thought, I decided to use a Arduino board as master, and the photoresistor board as slave. Eventually I will try to connect the LCD display to read the data.
I2C comunication works via 2 wires:
SDA: this is where the data travel.
SCL: this is the "timer", it allows the synchronization between the boards.
For the slave board I needed Tiny Wire library, so I downloaded it and I included it in my sketch. In the beginning I had some problems including it, that was because I had two installation of Arduino: one as root, and one as normal user and they didn't share the libraries. So I had unistall the normal user one and install all the libraries I needed on the root one.
These are the two boards connected, you can see 4 wires:

  • Orange: SCL
  • Black: SDA
  • Yellow: VCC
  • Blue: GND




This is the master code for the Arduino Duemilanove:

This is the slave code for the light sensor board, I uploaded it via ISP programmer:


The light sensor read the light in the room, then send it to the Arduino and write it on the serial:

Conclusions
I did something easy because this week was pretty hard to me, but still I really liked it. I've bought some manuals about networking because I really want to learn about it during this summer. Even if it was really hard to me, this was probably my favourite week.
Download
Master code
Slave code





Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.